package com.nanhai.buddhist.college.module.study.dal.mysql.classclockrecord;

import com.nanhai.buddhist.college.framework.common.pojo.PageResult;
import com.nanhai.buddhist.college.framework.mybatis.core.mapper.BaseMapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.nanhai.buddhist.college.module.study.controller.admin.classclockrecord.vo.ClockRecordExportReqVO;
import com.nanhai.buddhist.college.module.study.controller.admin.classclockrecord.vo.ClockRecordPageReqVO;
import com.nanhai.buddhist.college.module.study.controller.student.attendance.vo.StudentClockRecordPageReqVO;
import com.nanhai.buddhist.college.module.study.dal.dataobject.classclockrecord.ClockRecordDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 打卡记录 Mapper
 *
 * @author AKai
 */
@Mapper
public interface ClockRecordMapper extends BaseMapperX<ClockRecordDO> {

    default PageResult<ClockRecordDO> selectPage(ClockRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ClockRecordDO>()
                .eqIfPresent(ClockRecordDO::getWeekId, reqVO.getWeekId())
                .eqIfPresent(ClockRecordDO::getClassesId, reqVO.getClassesId())
                .eqIfPresent(ClockRecordDO::getSubjectId, reqVO.getSubjectId())
                .eqIfPresent(ClockRecordDO::getProfessionId, reqVO.getProfessionId())
                .eqIfPresent(ClockRecordDO::getCollegeId, reqVO.getCollegeId())
                .eqIfPresent(ClockRecordDO::getClockStatus, reqVO.getClockStatus())
                .geIfPresent(ClockRecordDO::getClockTime,reqVO.getClockStartTimeDate())
                .leIfPresent(ClockRecordDO::getClockTime,reqVO.getClockEndTimeDate())
                .geIfPresent(ClockRecordDO::getClockTime,reqVO.getWeekStartTimeDate())
                .leIfPresent(ClockRecordDO::getClockTime,reqVO.getWeekEndTimeDate())
                .eqIfPresent(ClockRecordDO::getDepartmentsId, reqVO.getDepartmentsId())
                .eqIfPresent(ClockRecordDO::getRoomId, reqVO.getRoomId())
                .inIfPresent(ClockRecordDO::getClassesId,reqVO.getClassesIds())
                .eqIfPresent(ClockRecordDO::getClockRole,reqVO.getRole())
                .eqIfPresent(ClockRecordDO::getClockUserId, reqVO.getClockUserId())
                .likeIfPresent(ClockRecordDO::getClockUserName, reqVO.getClockUserName())
                .eqIfPresent(ClockRecordDO::getUserPhone,reqVO.getUserPhone())
                .eqIfPresent(ClockRecordDO::getClockType, reqVO.getClockType())
                .eqIfPresent(ClockRecordDO::getHelpClockId, reqVO.getHelpClockId())
                .betweenIfPresent(ClockRecordDO::getClockTime, reqVO.getClockTime())
                .orderByDesc(ClockRecordDO::getCreateTime));
    }

    default List<ClockRecordDO> selectList(ClockRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ClockRecordDO>()
                .eqIfPresent(ClockRecordDO::getWeekId, reqVO.getWeekId())
                .eqIfPresent(ClockRecordDO::getClassesId, reqVO.getClassesId())
                .eqIfPresent(ClockRecordDO::getSubjectId, reqVO.getSubjectId())
                .eqIfPresent(ClockRecordDO::getRoomId, reqVO.getRoomId())
                .eqIfPresent(ClockRecordDO::getClockType, reqVO.getClockType())
                .eqIfPresent(ClockRecordDO::getHelpClockId, reqVO.getHelpClockId())
                .eqIfPresent(ClockRecordDO::getClockUserName, reqVO.getClockUserName())
                .betweenIfPresent(ClockRecordDO::getClockTime, reqVO.getClockTime())
                .orderByDesc(ClockRecordDO::getCreateTime));
    }

    default PageResult<ClockRecordDO> selectPage1(StudentClockRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ClockRecordDO>()
                .eqIfPresent(ClockRecordDO::getWeekId, reqVO.getWeekId())
                .eqIfPresent(ClockRecordDO::getClassesId, reqVO.getClassesId())
                .eqIfPresent(ClockRecordDO::getSubjectId, reqVO.getSubjectId())
                .geIfPresent(ClockRecordDO::getClockTime,reqVO.getClockStartTimeDate())
                .leIfPresent(ClockRecordDO::getClockTime,reqVO.getClockEndTimeDate())
                .eqIfPresent(ClockRecordDO::getRoomId, reqVO.getRoomId())
                .geIfPresent(ClockRecordDO::getClockTime,reqVO.getWeekStartTimeDate())
                .leIfPresent(ClockRecordDO::getClockTime,reqVO.getWeekEndTimeDate())
                .betweenIfPresent(ClockRecordDO::getClockTime,reqVO.getClockTime())
                .eqIfPresent(ClockRecordDO::getClockUserId,reqVO.getClockUserId())
                .eqIfPresent(ClockRecordDO::getClockType, reqVO.getClockType())
                .eqIfPresent(ClockRecordDO::getHelpClockId, reqVO.getHelpClockId())
                .eqIfPresent(ClockRecordDO::getClockStatus, reqVO.getClockStatus())
                .orderByDesc(ClockRecordDO::getCreateTime));
    }

}
